export default {
    namespaced: true,
    state: {
        isShowToast: false,
        toastMsg: "这是默认的提示信息",
        toastType: "warning",
    },
    mutations: {
        changeIsShowToast(state, payload) {
            state.isShowToast = payload.isShow;
            // 防止开启定时器关闭提示框，没赋值，得到空值，所以动画在消失过程时，会出现一个空白的椭圆;优化用户体验
            if (payload.isShow) {
                state.toastMsg = payload.msg;
                state.toastType = payload.type;
            }
        }
    },
    actions: {
        asyncShowToast(context, payload) {
            context.commit('changeIsShowToast', payload);
            setTimeout(() => {
                context.commit('changeIsShowToast', {
                    isShow: false
                })
            }, 2000)
        }
    }
}